<?php
namespace app\serverauthcode\service\authcode;
use \app\manage\service\ApiBase;
use think\Validate;

class ApiAuthCode extends ApiBase
{
    protected $addFields   = ["token"=>"", "appkey"=>"", "type"=>"", "code_id"=>"", "fontSize"=>25, "useCurve"=>1, "imageH"=>62, "imageW"=>250, "length"=>5];
    protected $authcodeValidate = 'app\serverauthcode\validate\AuthCode';
    protected $authcodeLogic    = '\app\serverauthcode\logic\AuthCode';

    public function createAuthCode()
    {
        if (empty($this->arrData)) {
            return null_data($this->arrData,"参数不能为空！");
        }
        $data = $this->receiveData($this->addFields);
        return $this->stepRun($data,'checkRepeat','add',$this->authcodeValidate,$this->authcodeLogic);
    }

    public function verifyAuthCode()
    {
        if (empty($this->arrData)) {
            return null_data($this->arrData,"参数不能为空！");
        }
        $data = $this->receiveData(["token"=>"", "appkey"=>"", "type"=>"", "code_id"=>"", "auth_code"=>""]);
        return $this->stepRun($data,'verifyAuthCode','verify',$this->authcodeValidate,$this->authcodeLogic);
    }
}